var event = require('events');

var EventEmitter=new event.EventEmitter();

EventEmitter.on('toparent',function(data){
    console.log('接收到广播事件');
    console.log('接受到的'+data);
});

setTimeout(() => {
    console.log('广播');
    EventEmitter.emit('toparent','发送的data');
}, 3000);